package cz.proks.easyhelpdesk.gwt.event;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

import cz.proks.easyhelpdesk.api.model.Helpdesk;
import cz.proks.easyhelpdesk.api.model.HelpdeskRole;
import cz.proks.easyhelpdesk.api.model.User;

public class MemberAddToHelpdeskEvent extends GwtEvent<MemberAddToHelpdeskEvent.Handler> {
    public final static Type<MemberAddToHelpdeskEvent.Handler> TYPE = new Type<MemberAddToHelpdeskEvent.Handler>();
    
    public static interface Handler extends EventHandler {
        void onMemberAddToHelpdesk(MemberAddToHelpdeskEvent event);
    }
    
    private final Helpdesk helpdesk;
    private final User user;
    private final HelpdeskRole role;

    public MemberAddToHelpdeskEvent(Helpdesk helpdesk, User user, HelpdeskRole role) {
        super();
        this.helpdesk = helpdesk;
        this.user = user;
        this.role = role;
    }
    
    public static void fireEvent(HasMemberAddToHelpdeskHandlers source, Helpdesk helpdesk, User user, HelpdeskRole role) {
        source.fireEvent(new MemberAddToHelpdeskEvent(helpdesk, user, role));
    }
    
    public Helpdesk getHelpdesk() {
        return helpdesk;
    }
    
    public User getMember() {
        return user;
    }
    
    public HelpdeskRole getRole() {
        return role;
    }

    @Override
    public com.google.gwt.event.shared.GwtEvent.Type<Handler> getAssociatedType() {
        return TYPE;
    }

    @Override
    protected void dispatch(Handler handler) {
        handler.onMemberAddToHelpdesk(this);
    }    
}
